#include "../core/engine/interface.h"
#include "statictext.h"

namespace sleek
{
    namespace gui
    {
        statictext::statictext(core::engine::interface *m) : frame(m)
        {
            isHovored = false;
        }
        statictext::~statictext()
        {
        }
        void statictext::setText(core::os::stringc t)
        {
            frame::setText(t);
            if(ft2) box.setSizeFromUpperLeft(ft2->getBoxSize()+10);
        }
        void statictext::setFont(font *i)
        {
            frame::setFont(i);
            if(ft2) box.setSizeFromUpperLeft(ft2->getBoxSize()+10);
        }
        void statictext::UpdateFontPos()
        {
            if(!ft2) return;
            textpos = absolute+relative;
            textpos.height += ft2->getBoxSize().height+4;
            textpos.width += 4;
        }
        bool statictext::manage(core::device::input *e)
        {
            bool CHovored = isHovored;
            if(frame::manage(e)) { return false; }
            if(e->type == core::device::EVENT_MOUSSE_MOVED) isHovored = box.intersect(e->mouse_pos);
            if(CHovored != isHovored)
            {
                e->gui.called = this;
                if(isHovored) { e->gui.code = gui::IET_STATICTEXT_HOVORED; return true; }
                else {  e->gui.code = gui::IET_STATICTEXT_FOCUSED; return true; }
            }
        }
        void statictext::render()
        {
            mom->getTheme()->drawStaticText(this);
        }
    }
}
